package com.wondertek.service.sdk.iotdh.config;

import cn.hutool.core.util.ObjectUtil;
import com.wondertek.common.exception.AppException;
import jakarta.annotation.PostConstruct;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;

@Data
@Configuration
@ConfigurationProperties(prefix = "dh.config")
@Validated
public class SdkConfig {

    public String clientId;

    public String clientSecret;

    public String baseUrl;

    @PostConstruct
    public void validate() {
        if(ObjectUtil.isEmpty(clientId) ||
           ObjectUtil.isEmpty(clientSecret) ||
           ObjectUtil.isEmpty(baseUrl)
        ){
            throw new AppException("缺少必要配置参数!");
        }
    }

}
